﻿using Microsoft.AspNetCore.Authentication.OAuth;
using Microsoft.AspNetCore.Authentication.OAuth.Claims;
using System.Collections.Generic;
using System.Security.Claims;

namespace Longbow.OAuth
{
    /// <summary>
    /// OAuthOptions 配置类
    /// </summary>
    public abstract class LgbOAuthOptions : OAuthOptions
    {
        /// <summary>
        /// 默认构造函数
        /// </summary>
        public LgbOAuthOptions()
        {
            ClaimActions.Add(new JsonKeyClaimAction(ClaimTypes.Name, ClaimValueTypes.String, "login"));
            Events.OnRemoteFailure = context =>
            {
                context.Response.Redirect(HomePath);
                context.HandleResponse();
                return System.Threading.Tasks.Task.CompletedTask;
            };
        }

        /// <summary>
        /// 获得/设置 登陆后首页
        /// </summary>
        public string HomePath { get; set; }

        /// <summary>
        /// 获得 配置授权角色列表
        /// </summary>
        public ICollection<string> Roles { get; } = new HashSet<string>();

        /// <summary>
        /// 获得/设置 默认授权 App
        /// </summary>
        public string App { get; set; }
    }
}
